//
//  LeftCell.m
//  liangyi
//
//  Created by 张水 on 16/12/16.
//  Copyright © 2016年 yswh. All rights reserved.
//

#import "LeftCell.h"

@implementation LeftCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

-(void)setLeftModel:(LeftModel *)leftModel{
    
    _leftModel = leftModel;
    [self.desImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",BaseIamgeUrl,leftModel.image]] placeholderImage:[UIImage imageNamed:@"img_placeholder"]];
    NSString *str = [NSString stringWithFormat:@"%@",leftModel.title];
    if (str.length > 12){
        NSString *str1 = [str substringToIndex:12];
        self.destitle.text = [NSString stringWithFormat:@"%@...",str1];
    }else{
        self.destitle.text = str;
    }
}


- (void)setupUI{
    self.desImage = [[UIImageView alloc]init];
    self.desImage.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:self.desImage];
    [self.desImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(10);
        make.width.height.equalTo(@60);
    }];
    self.destitle = [[UILabel alloc]init];
    self.destitle.textColor = [UIColor ColorWithHex:@"#686868"];
    self.destitle.font = [UIFont systemFontOfSize:17];
    self.destitle.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:self.destitle];
    [self.destitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.desImage.mas_right).offset(10);
        make.right.equalTo(self.contentView).offset(-5);
        make.centerY.equalTo(self.contentView.mas_centerY);
    }];
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [UIColor ColorWithHex:@"#ecf1f2"];
    [self.contentView  addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.height.equalTo(@1);
    }];
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
}


@end
